﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Collections;
using PPI.Entities.Lookup;

namespace PPI.Entities
{
    public class EBasePole : EBasePosition
    {
        #region Private Members
        private Int32 m_Id;
        private EBaseAsset m_Asset;
        private EXMissionStructures_PoleTopType m_TopType;
        private EXMissionStructures_PoleSpecies m_Species;
        private EXMissionStructures_PoleTreatment m_Treatment;
        private EXMissionStructures_PoleClass m_Class;
        private Int32 m_Year;
        private string m_AID;
        private Int32 m_LVisit;
        private string m_Number;
        private double m_Length;
        private string m_LVisitor;
        private List<EBaseAssetImage> m_Images; 
        
        #endregion

        #region Properties
        public Int32 Id
        {
            get
            {
                return m_Id;
            }
            set
            {
                m_Id = value;
            }
        }
        public EXMissionStructures_PoleTopType TopType
        {
            get
            {
                return m_TopType;
            }
            set
            {
                m_TopType = value;
            }
        }
        public EXMissionStructures_PoleSpecies Species
        {
            get
            {
                return m_Species;
            }
            set
            {
                m_Species = value;
            }
        }
        public EXMissionStructures_PoleTreatment Treatment
        {
            get
            {
                return m_Treatment;
            }
            set
            {
                m_Treatment = value;
            }
        }
        public EXMissionStructures_PoleClass Class
        {
            get
            {
                return m_Class;
            }
            set
            {
                m_Class = value;
            }
        }
        public Int32 Year
        {
            get
            {
                return m_Year;
            }
            set
            {
                m_Year = value;
            }
        }
        public string AID
        {
            get
            {
                return m_AID;
            }
            set
            {
                m_AID = value;
            }
        }
        public Int32 LVisit
        {
            get
            {
                return m_LVisit;
            }
            set
            {
                m_LVisit = value;
            }
        }
        public string Number
        {
            get
            {
                return m_Number;
            }
            set
            {
                m_Number = value;
            }
        }
        public double Length
        {
            get
            {
                return m_Length;
            }
            set
            {
                m_Length = value;
            }
        }
        public string LVisitor
        {
            get
            {
                return m_LVisitor;
            }
            set
            {
                m_LVisitor = value;
            }
        }
        public List<EBaseAssetImage> Images
        {
            get
            {
                return m_Images;
            }
            set
            {
                m_Images = value;
            }
        }
        public EBaseAsset Asset
        {
            get
            {
                return m_Asset;
            }
            set
            {
                m_Asset = value;
            }
        }

        public string Title
        {
            get
            {
                if (Id == Int32.MinValue)
                    return "Unsaved Pole";
                else
                    return "Pole_" + Id.ToString();
            }
        }

        #endregion

        #region Constructors

        public EBasePole()
            : base()
        {
            m_Id = Int32.MinValue;
            m_TopType = new EXMissionStructures_PoleTopType();
            m_Species = new EXMissionStructures_PoleSpecies();
            m_Treatment = new EXMissionStructures_PoleTreatment();
            m_Class = new EXMissionStructures_PoleClass();
            m_Year = Int32.MinValue;
            m_LVisit = Int32.MinValue;
            m_Asset = new EBaseAsset();
            m_Images = new List<EBaseAssetImage>();
        }

        public EBasePole(Int32 id)
            : this()
        {
            m_Id = id;
        }

        public EBasePole(Int32 id, EXMissionStructures_PoleTopType topType, EXMissionStructures_PoleSpecies species, EXMissionStructures_PoleTreatment treatment, EXMissionStructures_PoleClass pclass, Int32 year, string aid, Int32 lvisit, string number, double length, string lvisitor)
            : this(id)
        {
            m_TopType = topType;
            m_Species = species;
            m_Class = pclass;
            m_Length = length;
            m_LVisit = lvisit;
            m_LVisitor = lvisitor;
            m_Number = number;
            m_Treatment = treatment;
            m_Year = year;
            m_AID = aid;

        }





        #endregion

        #region Override Methods

        public override string GetHtmlPlacemark()
        {
            return GenerateHTML(this.Id);
        }

        public override string GetHtmlName()
        {

            string _Name = "";
            //switch (title)
            //{
            //    case EUtility_QueryAssetTextShow.Internal_Utility_ID:
            //        _Name = "Pole [ " + m_Id.ToString() + " ]";
            //        break;
            //    case EUtility_QueryAssetTextShow.AID:
            //        _Name = "Pole [  ]";
            //        break;
            //    case EUtility_QueryAssetTextShow.Top_Type:
            //        _Name = "Pole [ " + TopType.Name + " ]";
            //        break;
            //    default:
            //        break;
            //}
            return _Name;
        }

        public virtual string GenerateHTML(Int32 numberPole)
        {
            StringBuilder _Shtml = new StringBuilder();
            _Shtml.AppendLine("<table style='backgroundcolor:#ffffff' border='0'>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td><b>Pole " + numberPole + "</b></td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Top Type: " + TopType.Name + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>KV: " + TopType.Name + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Species: " + Species.Name + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Year: " + Year + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Treatment: " + Treatment.Name + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Length: " + Length + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Class: " + Class.Name + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Lat: " + Latitude.ToString("F6") + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>Long: " + Longitude.ToString("F6") + "</td>");
            _Shtml.AppendLine(" </tr>");
            _Shtml.AppendLine(" <tr>");
            _Shtml.AppendLine("     <td>ALt: " + Altitude.ToString() + "</td>");
            _Shtml.AppendLine(" </tr>");
            foreach (EBaseImage i in Images)
            {
                _Shtml.AppendLine(" <tr>");
                _Shtml.AppendLine(i.GenerateHTML());
                _Shtml.AppendLine(" </tr>");
            }
            _Shtml.AppendLine("</table>");
            return _Shtml.ToString();

        }

        #endregion

        public override bool Equals(object obj)
        {
            if (obj is EBasePole)
            {
                EBasePole tmbObj = (EBasePole)obj;
                return (tmbObj.Id == m_Id);
            }
            else
            {
                return false;
            }
        }



    }
}
